
Page({
  /**
   * 页面的初始数据
   */
  data: {
    post: "",
    show: false,
    getdata: {}
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  /**
   * 获取用户输入 
   */
  post: function (e) {
    console.log(e)
    this.setData({
      post: e.detail.value,
      show: false
    })
  },
  /**
   *用户点击获取数据事件 
   */
  btnClick: function (e) {
    var that = this;
    wx.showLoading({
      title: '加载中',
    });
    var post =this.data.post;
    console.log(post)
    if (post.length < 8) {
      wx.showToast({
        title: '编号不合法',
        icon: 'none',
        image: '../../images/error.png',
        duration: 2000
      })
      return false;
    }
    // 请求数据
    wx.request({
      // 780098068058
      url: "https://wxapi.hotapp.cn/proxy/?appkey=hotapp673617720&url=http://wuliu.market.alicloudapi.com/kdi?no="+post+"&type=auto",
      data: {
      },
      header: {
        'content-type': 'application/json', // 默认值
        'Authorization':'APPCODE af4807b326ce40908fde3c261e9322e4'
      },
      success: function (res) {
        console.log(res)
        wx.hideLoading();
        if (res.statusCode == 200) {
          if (res.data.status == 205) {
            wx.showModal({
              title: '提示',
              content: "暂时查询不到该订单的信息",
              success: function (res) {
                that.setData({
                  show: false
                })
              }
            })
          } else {
            that.setData({
              show: true,
              getdata: res.data.result
            })
          }
        } else {
          wx.showModal({
            title: '提示',
            content: res.data.msg,
            success: function (res) {
              that.setData({
                show: false
              })
            }
          })
        }
      }
    })
  }
})